# Copyright 2024 The DLRover Authors. All rights reserved.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

load("//:workspace.bzl", "cp_xpu_build_wheel_files")
load("@xpu_timer_cfg//:xpu_config.bzl", "XPU_TIMER_CONFIG")

filegroup(
    name = "srcs_py_xpu_timer",
    srcs = glob([
        "py_xpu_timer/*",
        "bin/*",
        "src/*",
        "setup.py",
    ]),
)


filegroup(
    name = "data_append_bin",
    srcs = [
        "//:libevent_hook.so",
        "//xpu_timer/python:libpy_tracing.so",
        "//xpu_timer/server:xpu_timer_daemon",
    ] + getattr(XPU_TIMER_CONFIG, "py_bin", []),
)

filegroup(
    name = "data_append_py",
    srcs = [
        "//xpu_timer/protos:hook_pb2.py",
        "//xpu_timer/protos:hosting_service_pb2.py",
        "@com_google_perfetto//:protos/perfetto/trace/perfetto_trace_pb2.py",
    ] + getattr(XPU_TIMER_CONFIG, "gen_symbol", []),
)

cp_xpu_build_wheel_files(
    name = "xpu_timer_wheel",
    srcs = [":srcs_py_xpu_timer"],
    append_bin = [":data_append_bin"],
    append_py = [":data_append_py"],
    dest = "dist",
)
